__author__ = 'F3285189'

from tkinter import *
from random import randint


class textWriter(Tk):
    ""
    def __init__(self, bgc, fgc, mystinrg):
        ""
        "Initialise TK widget by calling the TK init"
        Tk.__init__(self)
        "Initialise text sub widget"
        self.text = Text(self, background=bgc, foreground=fgc)
        self.text.pack()
        self.string = mystinrg
        self.sindex = 0
        self.displaystring()

    def displaystring(self):
        "Displays the input string one char at a time at random intervals"
        self.text.insert(INSERT, self.string[self.sindex])
        self.sindex += 1
        if self.sindex < len(self.string):
            self.after((10+(randint(10, 20)*(randint(1, 8)))), self.displaystring)

root = textWriter("black", "yellow", "Hello World .....!")
root.mainloop()